package io.ly.filte.filter;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * @Author LY
 * @create 2023/12/29 17:07
 * @Description filter实现:拦截所有请求过滤器，并将请求类型是HttpServletRequest类型的请求替换为自定义{@link io.ly.filte.filter.MyHttpServletRequestWrapper}
 */
@Configuration
@ServletComponentScan
@WebFilter(urlPatterns = "/*", filterName = "xssFilter")
public class MyFilter implements Filter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        chain.doFilter(new MyHttpServletRequestWrapper((HttpServletRequest) request),response);
    }
}
